package com.cn.intelligence.resetful.controller;


import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import com.cn.intelligence.pojo.Member;
import com.cn.intelligence.pojo.TaotaoResult;
import com.cn.intelligence.pojo.TbItem;
import com.cn.intelligence.pojo.TbItemCat;
import com.cn.intelligence.resetful.service.MemberService;

/**
 * Created by Administrator on 2017/4/18.
 */
@Controller
@RequestMapping("/member/")
public class MemberController {
    @Autowired
    private MemberService memberService;
    
    
    
    @RequestMapping("check")
    @ResponseBody
	public TaotaoResult getuser(String content){
		TaotaoResult taotaoResult = new TaotaoResult();
		taotaoResult = memberService.getuser(content);
		return taotaoResult;
	}
    
    
    /**
     * 查询书树节点信息
     * @param parentId
     * @return
     */
    @RequestMapping("list")
    @ResponseBody
    public List<Map<String,Object>> getCatList(@RequestParam(value = "id",defaultValue = "0") Long parentId){
    	
    	
    	List<Map<String,Object>> euTreeNodeList = memberService.getItemCatList(parentId);
        return euTreeNodeList;
    }
    

    /**
     * 查询书树节点信息
     * @param parentId
     * @return
     */
    @RequestMapping("catname")
    @ResponseBody
    public TaotaoResult getCatname(String catid){
    	TaotaoResult tbItemCat = memberService.getItemCatDesc(catid);
        return tbItemCat;
    }
    
    /**
     * 添加
     * @param parentId
     * @return
     */
    @RequestMapping("add")
    @ResponseBody
    public TaotaoResult addMember(Member member){    	
    	TaotaoResult resutl = memberService.addMember(member);
    	
        return resutl;
    }
    /**
     * 修改
     * @param parentId
     * @return
     */
    @RequestMapping(value = "updatefor",method = RequestMethod.POST)
    @ResponseBody
    public TaotaoResult update(Member member){    	
    	TaotaoResult resutl = memberService.updateItemCat(member);
    	
        return resutl;
    }
    /**
     * 结算
     * @param parentId
     * @return
     */
    @RequestMapping("jiesuan")
    @ResponseBody
    public TaotaoResult jiesuan(Long id){    	
    	TaotaoResult resutl = memberService.jiesuan(id);
    	
        return resutl;
    }
    /**
     * 修改
     * @param parentId
     * @return
     */
    @RequestMapping("delete")
    @ResponseBody
    public TaotaoResult deleteCat(Long id){    	
    	TaotaoResult resutl = memberService.deleteItemCat(id);
    	
        return resutl;
    }
}
